//
//  ShezhiViewController.m
//  tianjin
//
//  Created by 鞠超 on 16/8/12.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "ShezhiViewController.h"
#import "GuanyuwomenViewController.h"

@interface ShezhiViewController ()

@property (nonatomic, strong) UIScrollView * scrollView;

@end

@implementation ShezhiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void)p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    _topView.backgroundColor = [UIColor blackColor];
    
    _lblTitle.text = @"设置";
    _lblTitle.textColor = [UIColor whiteColor];
    _lblTitle.font = [UIFont systemFontOfSize:19];
    
    UIImageView * image_return = [[UIImageView alloc] initWithFrame:CGRectMake(15, 32, 10, 20)];
    image_return.image = [UIImage imageNamed:@"zuofanhui@2x.png"];
    [_topView addSubview:image_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 20, 35, 44);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.scrollView.contentSize = CGSizeMake(0, SCREEN_HEIGHT - 60);
    self.scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:self.scrollView];
    
    //1
    UIView * view_1 = [[UIView alloc] initWithFrame:CGRectMake(0, 15, SCREEN_WIDTH, 50)];
    view_1.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_1];
    
    UIImageView * image_1 = [[UIImageView alloc] init];
    image_1.frame = CGRectMake(10, 15, 20, 20);
    image_1.image = [UIImage imageNamed:@"gengxiss@2x.png"];
    [view_1 addSubview:image_1];
    
    UILabel * name_1 = [[UILabel alloc] init];
    name_1.frame = CGRectMake(CGRectGetMaxX(image_1.frame) + 10, 15, 150, 20);
    name_1.font = [UIFont systemFontOfSize:15];
    name_1.text = @"检查更新";
    [view_1 addSubview:name_1];
    
    UIImageView * image_icon1 = [[UIImageView alloc] init];
    image_icon1.frame = CGRectMake(SCREEN_WIDTH - 25, 17.5, 10, 15);
    image_icon1.image = [UIImage imageNamed:@"youfanhui@2x.png"];
    [view_1 addSubview:image_icon1];
    
    UIView * view_line1 = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
    view_line1.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_1 addSubview:view_line1];
    
    UIButton * btn_1 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_1.frame = CGRectMake(0, 0, SCREEN_WIDTH, 50);
    [view_1 addSubview:btn_1];
    [btn_1 addTarget:self action:@selector(btn_gengxin:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
    //2
    UIView * view_2 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(view_1.frame), SCREEN_WIDTH, 50)];
    view_2.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_2];
    
    UIImageView * image_2 = [[UIImageView alloc] init];
    image_2.frame = CGRectMake(10, 15, 20, 20);
    image_2.image = [UIImage imageNamed:@"guanyuw@2x.png"];
    [view_2 addSubview:image_2];
    
    UILabel * name_2 = [[UILabel alloc] init];
    name_2.frame = CGRectMake(CGRectGetMaxX(image_2.frame) + 10, 15, 150, 20);
    name_2.font = [UIFont systemFontOfSize:15];
    name_2.text = @"关于我们";
    [view_2 addSubview:name_2];
    
    UIImageView * image_icon2 = [[UIImageView alloc] init];
    image_icon2.frame = CGRectMake(SCREEN_WIDTH - 25, 17.5, 10, 15);
    image_icon2.image = [UIImage imageNamed:@"youfanhui@2x.png"];
    [view_2 addSubview:image_icon2];
    
    UIView * view_line2 = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
    view_line2.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_2 addSubview:view_line2];
    
    UIButton * btn_2 = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_2.frame = CGRectMake(0, 0, SCREEN_WIDTH, 50);
    [view_2 addSubview:btn_2];
    [btn_2 addTarget:self action:@selector(btn_guanyuwomen:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //退出
    UIButton * btn_tuichu = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_tuichu.frame = CGRectMake(15, CGRectGetMaxY(view_2.frame) + 30, SCREEN_WIDTH - 30, 45);
    btn_tuichu.backgroundColor = navi_bar_bg_color;
    btn_tuichu.layer.cornerRadius = 5;
    [btn_tuichu setTitle:@"退出登录" forState:(UIControlStateNormal)];
    [btn_tuichu setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    btn_tuichu.titleLabel.font = [UIFont systemFontOfSize:17];
    [self.scrollView addSubview:btn_tuichu];
    
    [btn_tuichu addTarget:self action:@selector(btn_tuichuAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

#pragma mark - 点击查看更新
- (void )btn_gengxin:(UIButton *)sender
{
//    NSLog(@"点击查看更新");
    
    UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"当前版本已经是最新版本啦" preferredStyle:(UIAlertControllerStyleAlert)];
    
    [self presentViewController:alert animated:YES completion:^{
        
    }];
    
    UIAlertAction * action = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alert addAction:action];
}

#pragma mark - 关于我们
- (void )btn_guanyuwomen:(UIButton *)sender
{
//    NSLog(@"关于我们");
    
    GuanyuwomenViewController * guanyuwomenViewController = [[GuanyuwomenViewController alloc] init];
    [self showViewController:guanyuwomenViewController sender:nil];
}

#pragma mark - 点击退出
- (void )btn_tuichuAction:(UIButton *)sender
{
//    NSLog(@"点击退出");
    
    UIAlertController * alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确定要退出登录" preferredStyle:(UIAlertControllerStyleAlert)];
    
    [self presentViewController:alert animated:YES completion:^{
        
    }];
    
    UIAlertAction * action1 = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alert addAction:action1];
    
    UIAlertAction * action = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
        
        NSLog(@"调取退出接口");
    }];
    [alert addAction:action];
}










@end
